namespace EyeOpen.Warehouse.Mvc.Helpers
{
	using System;
	using System.Web.Mvc.Ajax;

	public static class Helper
	{
		public const string UpdateTargetId = "aysnc";

		public const string DoneUpdateTargetId = "done";

		public static AjaxOptions DefaultOptions
		{
			get
			{
				return new AjaxOptions
					{
						HttpMethod = "Post", 
						InsertionMode = InsertionMode.Replace, 
						UpdateTargetId = UpdateTargetId
					};
			}
		}

		public static AjaxOptions DoneDefaultOptions
		{
			get
			{
				return new AjaxOptions
					{
						HttpMethod = DefaultOptions.HttpMethod, 
						InsertionMode = DefaultOptions.InsertionMode, 
						UpdateTargetId = DoneUpdateTargetId
					};
			}
		}

		public static AjaxOptions Change(this AjaxOptions options, Action<AjaxOptions> action)
		{
			action(options);

			return options;
		}
	}
}